
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>微行</title>
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    
    <script src="/Public/default/js/jquery-1.6.4.js" type="text/javascript"></script>
    <script src="/Public/default/js/weixin.js" type="text/javascript"></script>
    <script src="/Public/default/js/wxm-core1530d0.js" type="text/javascript"></script>

    
    <script type="text/javascript">
    var module = 'Info';
    var action = 'write';
    </script>

    <link rel="stylesheet" href="/Public/default/style/jquery.mobile-1.3.1.min.css" />
    <link rel="stylesheet" href="/Public/default/style/grid-listview.min.css" />
    <script src="/Public/default/js/jquery-1.8.2.js" type="text/javascript"></script>
    <script src="/Public/default/js/jquery.mobile-1.3.1.min.js" type="text/javascript"></script>
    <script src="/Public/default/js/WeixinJS.js"></script>

    <script src="/Public/default/js/alert.min.js"></script>

    <link href="/Public/default/style/jqm-demos.css" rel="stylesheet" />
    <link href="/Public/default/style/font-awesome.min.css" rel="stylesheet" />


</head>
<body>
    <div data-role="page" >


<script src="/Public/default/js/Menu.js?r=1"></script>
<script>
    $("div[data-role=page]").on("pagecreate", function () {
        $(this).find("a").each(function () {
            if ($(this).attr("data-ajax") != "true") {
                $(this).attr("data-ajax", "false");
            }
        });
        
        $("#dh").append("<li data-icon=\"arrow-r\"><a href=\"index.aspx\" target=\"_self\" title=\"首页\" data-theme=\"b\" data-transition=\"slidefade\" data-inline=\"true\">首页</a></li>");
        $.each(Menu, function (i) {
            $("#dh").append("<li data-icon=\"arrow-r\"><a href=\"" + this.url + "\" target=\"_self\" title=\"" + this.title + "\" data-theme=\"b\" data-transition=\"slidefade\" data-inline=\"true\">" + this.title + "</a></li>");
        })
        $("#dh").append("<li data-icon=\"delete\"><a href=\"#\" data-rel=\"close\">Close</a></li>");
        
    });
</script>

<div id="mypanel" data-role="panel" class="jqm-nav-panel jqm-navmenu-panel" data-position="left" data-display="reveal" data-theme="c">
    <ul data-role="listview" data-theme="d" data-divider-theme="d" data-icon="false" data-global-nav="demos" class="jqm-list" id="dh">
        <li data-role="list-divider">快速导航</li>

    </ul>
</div>

        <div data-role="content">
			<form id="myform" name="myform" method='post' action="/info/write">
                <div style="padding: 10px 20px;">
                    <h3>发布信息</h3>
                    <!-- <label for="catid">分类</label> -->
						<select name="catid" id="catid">
                            <volist name='type' id='v'>
                              <option value ="{$v.id}">{$v.name}</option>
                            </volist>
						</select>
                    <label for="title" class="ui-hidden-accessible">标题:</label>
                    <input name="title" id="title" value="" placeholder="输入标题" type="text" />

                    <label for="contact_user" class="ui-hidden-accessible">联系人:</label>
                    <input name="contact_user" id="contact_user" value="" placeholder="输入联系人" type="text" />

                    <label for="mobile" class="ui-hidden-accessible">手机号码:</label>
                    <input name="mobile" id="mobile" value="" placeholder="输入你的手机号码" type="text" />

                    <label for="qq" class="ui-hidden-accessible">QQ:</label>
                    <input name="qq" id="qq" value="" placeholder="输入你的QQ" type="text" />

                    <label for="content" class="ui-hidden-accessible">输入内容:</label>
                    <textarea name="content" id="content" placeholder="输入留言的内容"></textarea>
					
					<input name="verify_code" id="verify_code" value="" placeholder="输入验证码" style="width:150px;" maxlenght="4"> <img src="{:U('Public/verifycode')}">
                    
					<button type="button" data-theme="b" onclick="send()">发送</button>
					<input type="hidden" name="status" value="1" />
					<input type="hidden" name="aid" value="{$aid}" />
                    <input type="hidden" name="subflag" value="1" />
                </div>
        	</form>
		</div>
<script type="text/javascript">

//获取cookie
function getCookie(name){
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr != null)
		return unescape(arr[2]);
	else
		return null;
}
var aid=getCookie('aid');

    function send() {
    	myform = document.getElementById("myform");   
        if (myform.title.value == "") {
            alert("标题不能为空");
            myform.title.focus();
            return (false);
        }
        if (myform.contact_user.value== "") {
            alert("联系人不能为空");
            myform.contact_user.focus();
            return (false);
        }
        if (myform.qq.value == "" && myform.mobile.value == "") {
            alert("请留下您的QQ或手机号码以便我们和您联系");
            myform.mobile.focus();
            return (false);
        }
        if (myform.content.value == "") {
            alert("留言内容不能为空");
            myform.content.focus();
            return (false);
        }


         $.ajax({
            url: "{:U('Info/add')}",
            dataType: "json",
            type: "POST",
            data: $('#myform').serialize(),
            success: function (res) {
                alert(res.data);
                alert(typeof(res.data));
                switch(res.data){
	                case 1:
	                	alert("发布成功!");
	                	setTimeout('ok()',2000);
	                break;
	                case 0:
	                    alert(res.info);
	                break;                	
                }
            },
            error: function () {
                  alert("服务器错误,请稍后重试!");
            },
            timeout: 4000
         });
    }

    function ok(){
    	location.href="/m/info/index/aid/"+aid;
    }
</script>

<!-- 脚丫 -->

</div>

</body>
</html>